package com.sale.system.dubbo;

import com.sale.common.core.utils.BeanCopyUtils;
import com.sale.system.api.RemoteDeviceService;
import com.sale.system.api.domain.dto.DeviceApiRecordDto;
import com.sale.system.api.domain.vo.ReturnApiDeviceStatusVo;
import com.sale.system.domain.vo.ReturnDeviceStatusVo;
import com.sale.system.service.DeviceRecordService;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 设备dubbo实现层
 */
@RequiredArgsConstructor
@Service
@DubboService
public class RemoteDeviceServiceImpl implements RemoteDeviceService {

    @Resource
    DeviceRecordService deviceRecordService;


    /**
     * 设备状态回传（dubbo）
     */
    @Override
    public void returnDeviceStatus(ReturnApiDeviceStatusVo returnApiDeviceStatusVo) {
//        ReturnDeviceStatusVo returnDeviceStatusVo = new ReturnDeviceStatusVo();
//        returnDeviceStatusVo.setDeviceIds(returnApiDeviceStatusVo.getDeviceIds());
//        returnDeviceStatusVo.setStatus(returnApiDeviceStatusVo.getStatus());
        deviceRecordService.returnDeviceStatus(returnApiDeviceStatusVo);
    }

    /**
     * 根据id获取工艺卡信息
     */
    @Override
    public List<DeviceApiRecordDto> getDeviceByIds(String ids) {
        return deviceRecordService.getDeviceByIds(ids);
    }

    /**
     * 通过设备编码获取设备信息
     */
    @Override
    public DeviceApiRecordDto selectEquipmentById(String code) {
        return deviceRecordService.selectEquipmentById(code);
    }

    /**
     * 根据设备id获取信息
     */
    @Override
    public DeviceApiRecordDto getDeviceById(Long id) {
        return deviceRecordService.getDeviceById(id);
    }

    /**
     * 设备map列表
     */
    @Override
    public Map<String, DeviceApiRecordDto> getMapData() {
        return deviceRecordService.getMapData();
    }
}
